﻿using System;
using System.Runtime.Serialization;
using MultiViewer.Network;
using System.Windows.Controls;

namespace MultiViewer.Display.TiledImages
{
    [DataContract]
    public class SetVisibleRect : Message
    {
        private double xmin, ymin, xmax, ymax;

        [DataMember]
        public double Xmin
        {
            get { return xmin; }
            set { xmin = value; }
        }

        [DataMember]
        public double Xmax
        {
            get { return xmax; }
            set { xmax = value; }
        }

        [DataMember]
        public double Ymin
        {
            get { return ymin; }
            set { ymin = value; }
        }

        [DataMember]
        public double Ymax
        {
            get { return ymax; }
            set { ymax = value; }
        }

        public override string ToString()
        {
            return String.Format("[{0},{1}]x[{2},{3}]", xmin, xmax, ymin, ymax);
        }
    }

    [DataContract]
    public class ShowImage : Message
    {
        private string image;

        [DataMember]
        public string Image
        {
            get { return image; }
            set { image = value; }
        }
    }

    public class ImageTransactionState<TRequest> : TransactionState<TRequest> where TRequest: Message
    {
        private Canvas imageCanvas;

        public ImageTransactionState(TRequest request, Canvas c) : base(request)
        {
            imageCanvas = c;
        }

        public Canvas ImageCanvas
        {
            get { return imageCanvas; }
        }
    }

    public class ShowImageTransactionState : ImageTransactionState<ShowImage>
    {
        public ShowImageTransactionState(ShowImage request, Canvas c) : base(request, c)
        {
            // Nothing to do here
        }
    }

    public class SetVisibleRectTransactionState : ImageTransactionState<SetVisibleRect>
    {
        public SetVisibleRectTransactionState(SetVisibleRect request, Canvas c) : base(request,c)
        {
            // Nothing to do here
        }
    }
}